<?xml version="1.0" encoding="UTF-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>COMMAND Design Pattern</Title>
      <Author>LSANTANA</Author>
      <Description>Define uma interface nos moldes do framework Dao do siga2.</Description>
      <Shortcut>clRic</Shortcut>
    </Header>
    <Snippet>
      <Declarations>
		<Object>
          <ID>Command</ID>
          <Type>Object</Type>
          <ToolTip></ToolTip>
          <Default>[Command]</Default>
        </Object>
		<Object>
          <ID>ConcreteCommand</ID>
          <Type>Object</Type>
          <ToolTip></ToolTip>
          <Default>[ConcreteCommand]</Default>
        </Object>
        <Object>
		  <ID>Client</ID>
          <Type>Object</Type>
          <ToolTip></ToolTip>
          <Default>[Client]</Default>
        </Object>
        <Object>
		  <ID>Invoker</ID>
          <Type>Object</Type>
          <ToolTip></ToolTip>
          <Default>[Invoker]</Default>
        </Object>
        <Object>
		  <ID>Receiver</ID>
          <Type>Object</Type>
          <ToolTip></ToolTip>
          <Default>[Receiver]</Default>
        </Object>
      </Declarations>
      <Code Language="VB" Kind="file"><![CDATA[
'The classes and/or objects participating in this pattern are:
'
'    Command  ($Command$ ex.: Command)
'        declares an interface for executing an operation
'    ConcreteCommand  ($ConcreteCommand$ ex.: CalculatorCommand)
'        defines a binding between a Receiver object and an action
'        implements Execute by invoking the corresponding operation(s) on Receiver
'    Client  ($Client$ ex.: CommandApp)
'        creates a ConcreteCommand object and sets its receiver
'    Invoker  ($Invoker$ ex.: User)
'        asks the command to carry out the request
'    Receiver  ($Receiver$ ex.: Calculator)
'        knows how to perform the operations associated with carrying out the request.

Namespace DoFactory.GangOfFour.Command.Structural

    ''' <summary>
    ''' MainApp startup class for Structural
    ''' Command Design Pattern.
    ''' </summary>
    Public Class MainApp

        ''' <summary>
        ''' Entry point into console application.
        ''' </summary>
        Public Shared Sub Main()

            ' Create receiver, command, and invoker
            Dim receiver As New $Receiver$()

            Dim command As $Command$ = New $ConcreteCommand$(receiver)

            Dim invoker As New $Invoker$()

            ' Set and execute command
            invoker.SetCommand(command)
            invoker.ExecuteCommand()

            ' Wait for user
            'Console.ReadKey()

        End Sub

    End Class

    ''' <summary>
    ''' The 'Command' abstract class
    ''' </summary>
    MustInherit Class $Command$

        Protected receiver As Receiver

        ' Constructor
        Public Sub New(ByVal receiver As Receiver)
            Me.receiver = receiver
        End Sub

        Public MustOverride Sub Execute()

    End Class

    ''' <summary>
    ''' The 'ConcreteCommand' class
    ''' </summary>
    Class $ConcreteCommand$
        Inherits $Command$

        ' Constructor
        Public Sub New(ByVal receiver As Receiver)
            MyBase.New(receiver)
        End Sub

        Public Overrides Sub Execute()
            receiver.Action()
        End Sub

    End Class

    ''' <summary>
    ''' The 'Receiver' class
    ''' </summary>
    Class $Receiver$

        Public Sub Action()
            Console.WriteLine("Called Receiver.Action()")
        End Sub

    End Class

    ''' <summary>
    ''' The 'Invoker' class
    ''' </summary>
    Class $Invoker$

        Private _command As $Command$

        Public Sub SetCommand(ByVal command As $Command$)
            Me._command = command
        End Sub

        Public Sub ExecuteCommand()
            _command.Execute()
        End Sub

    End Class

End Namespace

  
]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>